package net.jxta.myjxta;

import javax.swing.JFrame;

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;

import net.jxta.myjxta.util.Resources;

public class Welcome extends JFrame{
	
	private Image image=null;
	
	public  Welcome(){
		
		setSize(640,400);
		Dimension screenSize=Toolkit.getDefaultToolkit().getScreenSize(); 
	    Dimension frameSize=this.getSize();
		if(frameSize.height>screenSize.height) frameSize.height=screenSize.height; 
	    if(frameSize.width>screenSize.width) frameSize.width=screenSize.width; 
	    setLocation((screenSize.width-frameSize.width)/2, (screenSize.height-frameSize.height)/2);
		setUndecorated(true);
		
		image=Resources.getInstance().getIconResource("Welcome").getImage();
		
		this.addMouseListener(new MouseAdapter(){
	
			public void mouseClicked(MouseEvent event){
				setVisible(false);
				startVNLab();
	
			}
		});
		this.addKeyListener(new KeyAdapter(){
	
			public void keyPressed(KeyEvent event){
				setVisible(false);
				startVNLab();
	
			}
		});
		this.addMouseWheelListener(new MouseAdapter(){
			
			public void mouseWheelMoved(MouseWheelEvent event){
				setVisible(false);
				startVNLab();
			}
		});	
	}
	
	public void paint(Graphics g){
		super.paint(g);
		g.drawImage(image,0,0,640,400,this);

	}
	
	public void startVNLab(){
		
        StartVNLab vnlab=new StartVNLab("vnlab");
		vnlab.start();	
		
	}
}
